package hu.rsc.forbiddenwords.shared;

import com.google.gwt.user.client.rpc.IsSerializable;

public class ColumnFilterInfo implements IsSerializable {

    private int column;
    private String filter;
    private boolean isText = true;
    private boolean negated = false;

    public ColumnFilterInfo() {
	// serializalashoz
    }

    /**
     * Constructor.
     * 
     * @param column
     *            a szűrt oszlopindex
     * @param filterText
     *            a szűrés értéke (amit megad a user)
     */
    public ColumnFilterInfo(int column, String filterText) {
	this.column = column;
	this.filter = filterText;
    }

    public ColumnFilterInfo(int column, String filterText, boolean isText) {
	this.column = column;
	this.filter = filterText;
	this.isText = isText;
    }

    public ColumnFilterInfo(int column, String filterText, boolean isText, boolean negated) {
	this.column = column;
	this.filter = filterText;
	this.isText = isText;
	this.negated = negated;
    }

    /**
     * Check if this object is equal to another. The objects are equal if the column and filter values are equal.
     * 
     * @param csi
     *            the other object
     * @return true if objects are the same
     */
    public boolean equals(ColumnFilterInfo cfi) {
	if (cfi == null) {
	    return false;
	}
	return ((this.getColumn() == cfi.getColumn()) && (this.filter.equals(cfi.getFilter())));
    }

    @Override
    public boolean equals(Object obj) {
	if (obj instanceof ColumnFilterInfo) {
	    return this.equals((ColumnFilterInfo) obj);
	}
	return false;
    }

    /**
     * @return a szűrt oszlopindex
     */
    public int getColumn() {
	return this.column;
    }

    /**
     * @return a szűrés értéke (amit megad a user)
     */
    public String getFilter() {
	return this.filter;
    }

    @Override
    public int hashCode() {
	return super.hashCode();
    }

    public boolean isNegated() {
	return this.negated;
    }

    public boolean isText() {
	return this.isText;
    }

    /**
     * @param column
     *            a szűrt oszlopindex
     */
    public void setColumn(int column) {
	this.column = column;
    }

    /**
     * @param filterText
     *            a szűrés értéke (amit megad a user)
     */
    public void setFilter(String filterText) {
	this.filter = filterText;
    }

    public void setNegated(boolean negated) {
	this.negated = negated;
    }

    public void setText(boolean isText) {
	this.isText = isText;
    }
}